package pack0625;

import java.util.Scanner;

public class Count {

     Person per;
     Computer com;

    public Count(){
        System.out.println("请输入您的名字");
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        per = new Person(str);
        com = new Computer("李钊");
    }
    private void Sanjuliangsheng(){
        int zongjushu = 0;
        while (zongjushu<3){
            int pHand = per.showHand();
            int cHand = com.showHand();
            System.out.println(per.name+"出拳"+per.type);
            System.out.println(com.name+"出拳"+com.type);
                if (pHand==1 && cHand==2 || pHand==2 && cHand==3 || pHand==3 && cHand==1){
                    System.out.println(per.getName()+":此局举获胜");
                    per.addScore();
                }else if(pHand==cHand){
                    System.out.println("平局");
                }else {
                    com.addScore();
                    System.out.println(com.getName()+":此局获胜");
                }
                zongjushu++;
        }
    }

    public void Jieguo(){
        int pScore = per.getScore();
        int cScore = com.getScore();
        if (pScore>cScore){
            System.out.println(per.getName()+":赢了,真鸡儿棒");
        }else if (pScore==cScore){
            System.out.println("平局");
        }else {
            System.out.println(com.getName()+":赢了");
        }
        System.out.println(per.getName()+":"+com.getName()+"="+per.getScore()+":"+com.getScore());
        }
        public void start(){
            while (true){
                Sanjuliangsheng();
                Jieguo();
                System.out.println("是否继续? [0] 是  [1] 否");
                Scanner scanner = new Scanner(System.in);
                int n = scanner.nextInt();
                if (n==0){
                    continue;
                }else {
                    break;
                }
            }
        }
}
